//
//  main.m
//  03-homework
//
//  Created by dllo on 16/7/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "BookManager.h"
#import "Book.h"
int main(int argc, const char * argv[]) {
   
    // 1.截取字符串 "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
    NSString *str = @"20|https://www.baidu.com";
    NSArray *arr = [str componentsSeparatedByString:@"|"];
    NSLog(@"arr= %@", arr);
    // 2.向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
    int a = 10;
    NSNumber *numberOfInt = [NSNumber numberWithInt:a];
    float b = 2.5;
    NSNumber *numberOfFloat = [NSNumber numberWithFloat:b];
    double c = 5.1111;
    NSNumber *numberOfDouble = [NSNumber numberWithDouble:c];
    BOOL d = YES;
    NSNumber *numberOfBool = [NSNumber numberWithBool:d];
    NSMutableArray *mutableArr = [NSMutableArray array];
    [mutableArr addObject:numberOfInt];
    [mutableArr addObject:numberOfFloat];
    [mutableArr addObject:numberOfDouble];
    [mutableArr addObject:numberOfBool];
    // 3.实现图书管理系统(BookManager类)：
    // (1)使用数组管理所有书籍(Book类)。
    // (2)BookManager类属性数组可以添加、删除。
    // (3)可以从数组根据书名查找书籍，并修改书籍的价格。
    // (4)展示所有书籍清单（书名）
    //创建数学,科学,语文,英语四本书及其相应的价格
    Book *bookOfMath = [Book bookWithName:@"math" price:25.5];
    NSLog(@"bookOfMath:%@", bookOfMath);
    Book *bookOfScience = [Book bookWithName:@"science" price:20.4];
    NSLog(@"bookOfScience:%@", bookOfScience);
    Book *bookOfChinese = [Book bookWithName:@"chinese" price:31.8];
    NSLog(@"bookOfChinese:%@", bookOfChinese);
    Book *bookOfEnglish = [Book bookWithName:@"English" price:24.6];
    NSLog(@"bookOfEnglish:%@", bookOfEnglish);
    BookManager *bookManager = [[BookManager alloc] init];
    bookManager.books = [NSMutableArray arrayWithObjects:bookOfMath, bookOfScience, bookOfChinese, bookOfEnglish, nil];
    //新建一本音乐书,及其价格
    Book *bookOfMusic = [Book bookWithName:@"music" price:26.1];
    //将音乐书放入数组中
    [bookManager.books insertObject:bookOfMusic atIndex:2];
    //找出数学书,并修改数学书的价格
    [bookManager changeBookPrice:@"math" price:23.5];
    //展示所有书籍清单(书名)
    [bookManager showAllBookNames];
    //展示所有信息
    [bookManager showAllBookInformation];
    //根据书名,显示该书的详细信息
    [bookManager searchBookFromName:@"math"];
    //删除所有信息
    
    return 0;
}
